<meta charset="utf-8">
<title>西游记</title>
<img src="13.jpg" id="pid">
<button id="but" onclick = "fun1()">播放</button>
<script>
         var i=13;
        function fun(){
              pid.src = i+".jpg";
              i++;
              if(i==20){
                   i=13;
               }
       }

        function fun1(){
        if(but.innerHTML=="播放")
        {
         time1=setInterval(fun,100);
         but.innerHTML="暂停";
         }else{
         clearInterval(time1);
         but.innerHTML="播放";
         } 
         }
</script>